home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 03 - 1987 / 03.10 Oct 87 / basic source / ZFinder.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-08-17  |  2.0 KB  |  65 lines  |  [TEXT/QEDZ]

  1. REM ZBasic Quick Finder
  2. REM ©MacTutor and Zedcor, 1987
  3. REM Adapted from E-159 of ZBasic Manual
  4. REM By Dave Kelly
  5.  
  6. REM This program allows you to Execute other applications
  7. REM and return with all variables as they were
  8. REM THIS APPLICATION MUST BE IN SYSTEM FOLDER TO WORK WITH HFS
  9. REM NOTE: ALL VARIABLES ARE RESTORED UPON RETURN TO THIS PROGRAM
  10.  
  11. WINDOW OFF
  12. WINDOW#1,"",(100,30)-(400,90),2
  13. CurApName&=&910
  14. FinderName&=&2E0
  15. I=0
  16. FirstVariable%=0
  17. GOSUB "Get Last Variable pointer"
  18.  
  19. REM Check to see if returning from another application
  20. OPEN"R",1,"ZVARS"        REM    If returning from an application
  21. LONG IF LOF(1,1)>10    REM    reload all the variables
  22.     READ FILE #1,VARPTR(FirstVariable%), LastVariable&-VARPTR(FirstVariable%)
  23.     TEXT 2,12,1
  24.     PRINT"Last Application: ";:PRINT Application$
  25.     PRINT"Elapsed Time: ";TIMER-StartTime&;" Seconds"
  26. XELSE
  27.     TEXT 2,12,1
  28.     PRINT SPC(5);"Welcome to Macintosh."
  29.     SysLength=PEEK(FinderName&)
  30.     SystemFinder$=""
  31.     FOR I=1 TO SysLength
  32.         SystemFinder$=SystemFinder$+CHR$(PEEK(FinderName&+I))
  33.     NEXT
  34.     REM SystemFinder$ is the name of the original Startup appl.
  35. END IF
  36. PRINT"Please select an application to run."
  37. StartTime&=TIMER
  38.  
  39. REM Moves This Applications filename to FinderName global variable
  40. FOR I=0 TO 15: REM Your filename MUST be less than 16 char's
  41.     POKE FinderName&+I,PEEK(CurApName&+I)
  42. NEXT
  43. REM *** Get name of application to execute
  44. Application$=FILES$(1,"APPL",,Volume%):REM APPL=any executable file
  45. REM Last variable used as dummy for READ FILE and WRITE FILE
  46. LONG IF Application$=""
  47.     CLOSE #1
  48.     KILL "ZVARS"
  49.     REM Restore Finder filename as desktop start-up
  50.     POKE FinderName&,SysLength
  51.     FOR I=1 TO LEN(SystemFinder$)+1
  52.         POKE FinderName&+I,PEEK(VARPTR(SystemFinder$)+I)
  53.     NEXT
  54. XELSE
  55.     RECORD#1,0,0:REM Reset file pointer to beginning of file
  56.     REM *** Save Variables before executing Application
  57.     WRITE FILE #1,VARPTR(FirstVariable%), LastVariable&-VARPTR(FirstVariable%)
  58.     CLOSE#1
  59.     REM Execute Application now...
  60.     RUN Application$,Volume%
  61. END IF
  62. END
  63. "Get Last Variable pointer"
  64. LastVariable&=VARPTR(LastVariable%)
  65. RETURN